home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
listings
/
v_12_05
/
saks
/
lns1b.cpp
< prev
next >
Wrap
C/C++ Source or Header
|
1994-03-08
|
631b
|
37 lines
Listing 7 - member function definitions for lns using a pair of pointers
//
// lns1b.cpp - line number sequence implementation
//
#include <stdio.h>
#include "lns.h"
lns::lns(unsigned n)
{
first = last = new node(n);
}
lns::~lns()
{
node *p;
while ((p = first) != 0)
{
first = first->next;
delete p;
}
}
void lns::add(unsigned n)
{
if (last->number != n)
last = last->next = new node(n);
}
void lns::print()
{
node *p;
for (p = first; p != 0; p = p->next)
printf(" %4d", p->number);
}